/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package isvp.test;

import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;

/**
 *
 * @author jjophin
 */
public class ReadFile {
    public static void readFile(InputStream in, ZipEntry entry) {
        //StringBuffer xmlString = new StringBuffer();
        
        String xmlString = "";
        byte[] buffer = new byte[1000000];
        int length = 0;
        long size = entry.getSize();
        int n = 0;
        //try {
            //n = in.read(buffer, offset, length);
            try {
                while (length < size && -1 != (n = in.read(buffer))) {
                    xmlString += new String(buffer, 0, n);
                    //xmlString.append(new String(buffer, 0, n));
                    length += n;
                }
                System.out.println(xmlString);
            } catch (IOException ex) {
                Logger.getLogger(ReadFile.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                try {
                    in.close();
                } catch (IOException ex) {
                    Logger.getLogger(ReadFile.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        } /*catch (IOException ex) {
            Logger.getLogger(ReadFile.class.getName()).log(Level.SEVERE, null, ex);
        }*/
    
        public static void readSaxFile() throws ParserConfigurationException, SAXException {
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser parser = spf.newSAXParser();
            //parser.parse(InputStream in, new HandlerBase());
        }
    }

